Copyright: Copyright (c) 1994 SoftCircuits Programming


Help Contents
VB-Helper Help Contents

VB-Helper, Version 1.02

Copyright © 1994 SoftCircuits Programming

Redistributed by Permission.

Select from one of the following items to view the associated help topic:

Overview

Conditions for Distribution

Using VB-Helper

Subroutines

vbFullPath

vbGetCtrlModel

vbGetData

vbGetFullPath

vbGetLongPtr

vbInp

vbInpw

vbInterrupt

vbInterruptX

vbOut

vbOutw

vbPeek

vbPeekw

vbPoke

vbPokew

vbRecreateCtrl

vbSetData

vbVarPtr

vbVarSeg

User-Defined Types

MODEL

REGS

VB-Helper Revision History


SoftCircuits
VB-Helper was created by:

P.O. Box 16262

Irvine, CA 92713

CompuServe: 72134,263

Thanks also to Douglas Marquardt, Louie McCaw and Larry Rebich for their suggestions and/or assistance.

Please let us know if you find a problem or have a suggestion for this program or the associated documentation. If your suggestion is used, we will be happy to add your name to the list above.


Overview

VB-Helper is a DLL that was written to help Visual Basic programmers accomplish tasks that are either very difficult or impossible to do in Visual Basic alone. Although there are other DLLs and VBXs that can accomplish these same tasks, VB-Helper has its own collection of routines in a single DLL, and may be used and distributed free of charge provided that you agree to the conditions set forth in this help file.

This DLL was created to provide help to other Visual Basic programmers. If you find a problem or have a suggestion for this program or the associated documentation, please share your knowledge. If your suggestion is used, we will be happy to add your name to the authors topic in this help file.


Conditions for Distribution

This program may be used and distributed freely on the condition that it is distributed in full and unchanged, and that no fee is charged for such use and distribution with the exception or reasonable media and shipping charges.

You may also incorporate any or all portions of this program, and/or include the VB-Helper DLL, as part of your own programs and distribute such programs without payment of royalties on the condition that such program do not duplicate the overall functionality of VB-Helper and/or any of its demo programs, and that you agree to the following disclaimer:

WARNING: Accessing the low-level services of Windows, DOS and the ROM-BIOS using VB-Helper is an extremely powerful technique that, if used incorrectly, can cause possible permanent damage and/or loss of data. You are responsible for determining appropriate use of any and all files included in this package. SoftCircuits will not be held liable for any damages resulting from the use of these files.

SOFTCIRCUITS SPECIFICALLY DISCLAIMS ALL WARRANTIES, INCLUDING, WITHOUT LIMITATION, ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF THIRD PARTY RIGHTS.

UNDER NO CIRCUMSTANCES WILL SOFTCIRCUITS BE LIABLE FOR SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT, OR ANY OTHER DAMAGES OR CLAIMS ARISING FROM THE USE OF THIS PRODUCT, INCLUDING LOSS OF PROFITS OR ANY OTHER COMMERCIAL DAMAGES, EVEN IF WE HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Please contact SoftCircuits Programming if you have any questions concerning these conditions.


Using VBHelper
Using VB-Helper

To use VB-Helper in your Visual Basic program, you should copy the VBHELPER.TXT file to one of the BAS modules in your project. This file contains the declarations for all of the VB-Helper subroutines. You can call these routines as you would call any other DLL routines.

The DLL (VBHELPER.DLL) must either be in the current directory, the Windows or Windows system directory, or on the DOS path. If you place it in the Windows system directory, it will be available to all of your VB programs.

See the Visual Basic documentation for additional information about calling DLL routines from Visual Basic.

WARNING: Visual Basic prevents you from making most errors that would adversly affect the system. When you use this or any other DLL, Visual Basic can no longer prevent these type of errors. Under Windows protected mode, most errors will results in a General Protection Fault (GPF). However, it is possible, using VB-Helper, to corrupt Windows, DOS or even the files on your disk. Use caution when working with any DLL and be sure to save and backup your files often.


REGS User-Defined Type

The REGS structure is used by the vbInterrupt and vbInterruptX subroutines. It is used to specify and return the register values used by the interrupt.

Type REGS

AX As Integer	'General-purpose registers

BX As Integer

CX As Integer

DX As Integer

SI As Integer

DI As Integer

Flags As Integer	'Flags register

DS As Integer	'Segment registers

ES As Integer

End Type


MODEL User-Defined Type

The MODEL structure is used internally by Visual Basic controls.

Type MODEL

usVersion As Integer	'VB version used by control

fl As Long	'Bitfield structure

pctlproc As Long	'The control proc.

fsClassStyle As Integer	'Window class style

flWndStyle As Long	'Default window style

cbCtlExtra As Integer	'# bytes alloc'd for HCTL structure

idBmpPalette As Integer	'BITMAP id for tool palette

npszDefCtlName As Integer	'Default control name prefix

npszClassName As Integer	'Visual Basic class name

npszParentClassName As Integer	'Parent window class if subclassed

npproplist As Integer	'Property list

npeventlist As Integer	'Event list

nDefProp As String * 1	'Index of default property

nDefEvent As String * 1	'Index of default event

nValueProp As String * 1	'Index of control value property

usCtlVersion As Integer	'Identifies the current version of the custom control. The values 1

End Type	'and 2 are reserved for custom controls created with VB 1.0 and 2.0


vbFullPath

Declaration:	Declare Function vbFullPath Lib "VBHELPER.DLL" (ByVal szPartialPath As String, ByVal szFullPath As String, ByVal MaxLen As Integer) As Integer

Description:	This subroutine is included for compatibility with previous versions of VB-Helper. You should instead use vbGetFullPath.


vbGetCtrlModel

Declaration:	Declare Function vbGetCtrlModel Lib "VBHELPER.DLL" (ByVal Ctrl As Long) As Long

Description:	This function returns a long pointer to the MODEL structure used by Ctrl.

See Also:	vbRecreateCtrl


vbGetData

Declaration:	Declare Sub vbGetData Lib "VBHELPER.DLL" (ByVal Pointer As Long, Variable As Any, ByVal nCount As Integer)

Description:	Copies the data from the memory location pointed to by Pointer to Variable. nCount specifies the number of bytes to be copied. This function is useful if you need to access data not within your program.

See Also:	vbSetData


vbGetFullPath

Declaration:	Declare Function vbGetFullPath Lib "VBHELPER.DLL" (PartialPath As String) As String

Description:	Returns an absolute path name from the relative path name specified by PartialPath. If PartialPath contains an invalid path specifier, or any other error occurs, an empty string ("") is returned.


vbGetLongPtr

Declaration:	Declare Function vbGetLongPtr Lib "VBHELPER.DLL" (Variable As Any) As Long

Description:	Returns a long value that contains the address of Variable.. The high-order word contains the segment portion and the low-order word contains the offset portion.

Note that there are special considerations when obtaining the address of string variables.

See Also:	vbVarPtr, vbVarSeg


vbInp

Declaration:	Declare Function vbInp Lib "VBHELPER.DLL" (ByVal nPort As Integer) As Integer

Description:	Reads a byte value from the specified I/O port.

Note that under Windows protected mode, VxD drivers can lock access to an I/O port. Attempting to illegally access a locked port will generate a general protection fault (GPF).

See Also:	vbInptw, vbOut


vbInpw

Declaration:	Declare Function vbInpw Lib "VBHELPER.DLL" (ByVal nPort As Integer) As Integer

Description:	Reads a word value from the specified I/O port.

Note that under Windows protected mode, VxD drivers can lock access to an I/O port. Attempting to illegally access a locked port will generate a general protection fault (GPF).

See Also:	vbInp, vbOutw


vbInterrupt

Declaration:	Declare Sub vbInterrupt Lib "VBHELPER.DLL" (ByVal IntNum As Integer, InRegs As REGS, OutRegs As REGS)

Description:	Calls an interrupt (DS and ES are ignored). IntNum is the interrupt to be called. InRegs contains the registers to be passed to the interrupt, and OutRegs contains the registers returned by the the interrupt.

Note that under Windows protected mode, some DOS and BIOS interrupts that accept addresses will be expecting real-mode addresses and may behave unexpectedly when called from Windows.

See Also:	vbInterruptX


vbInterruptX

Declaration:	Declare Sub vbInterruptX Lib "VBHELPER.DLL" (ByVal IntNum As Integer, InRegs As REGS, OutRegs As REGS)

Description:	Calls an interrupt (DS and ES are used). IntNum is the interrupt to be called. InRegs contains the registers to be passed to the interrupt, and OutRegs contains the registers returned by the the interrupt.

Note that under Windows protected mode, some DOS and BIOS interrupts that accept addresses will be expecting real-mode addresses and may behave unexpectedly when called from Windows.

See Also:	vbInterrupt


vbOut

Declaration:	Declare Sub vbOut Lib "VBHELPER.DLL" (ByVal nPort As Integer, ByVal nData As Integer)

Description:	Sends a byte value to the specified I/O port.

Note that under Windows protected mode, VxD drivers can lock access to an I/O port. Attempting to illegally access a locked port will generate a general protection fault (GPF).

See Also:	vbInp, vbOutw


vbOutw

Declaration:	Declare Sub vbOutw Lib "VBHELPER.DLL" (ByVal nPort As Integer, ByVal nData As Integer)

Description:	Sends a word value to the specified I/O port.

Note that under Windows protected mode, VxD drivers can lock access to an I/O port. Attempting to illegally access a locked port will generate a general protection fault (GPF).

See Also:	vbInpw, vbOut


vbPeek

Declaration:	Declare Function vbPeek Lib "VBHELPER.DLL" (ByVal nSegment As Integer, ByVal nOffset As Integer) As Integer

Description:	Returns the byte value at the memory location specified by nSegment and nOffset.

Due to the nature of Windows protected mode, nSegment must be &H0000, &H0040, &HA000, &HB000, &HC000, &HD000, &HE000 or &HF000 or the call is ignored.

See Also:	vbPeekw, vbPoke


vbPeekw

Declaration:	Declare Function vbPeekw Lib "VBHELPER.DLL" (ByVal nSegment As Integer, ByVal nOffset As Integer) As Integer

Description:	Returns the word value at the memory location specified by nSegment and nOffset.

Due to the nature of Windows protected mode, nSegment must be &H0000, &H0040, &HA000, &HB000, &HC000, &HD000, &HE000 or &HF000 or the call is ignored.

See Also:	vbPeek, vbPokew


vbPoke

Declaration:	Declare Sub vbPoke Lib "VBHELPER.DLL" (ByVal nSegment As Integer, ByVal nOffset As Integer, ByVal nValue As Integer)

Description:	Writes the byte value specified by nValue to the memory location specified by nSegment and nOffset.

Due to the nature of Windows protected mode, nSegment must be &H0000, &H0040, &HA000, &HB000, &HC000, &HD000, &HE000 or &HF000 or the call is ignored.

See Also:	vbPeek, vbPokew


vbPokew

Declaration:	Declare Sub vbPokew Lib "VBHELPER.DLL" (ByVal nSegment As Integer, ByVal nOffset As Integer, ByVal nValue As Integer)

Description:	Writes the word value specified by nValue to the memory location specified by nSegment and nOffset.

Due to the nature of Windows protected mode, nSegment must be &H0000, &H0040, &HA000, &HB000, &HC000, &HD000, &HE000 or &HF000 or the call is ignored.

See Also:	vbPeekw, vbPoke


vbRecreateCtrl

Declaration:	Declare Function vbRecreateCtrl Lib "VBHELPER.DLL" (ByVal Ctrl As Long) As Integer

Description:	This function destroys the control specified by Ctrl and then recreates it. This is useful when you need to specify attributes, for the window associated with a control, that cannot normally be modified once the window has been created.

If successful, this function returns True. False is returned if the control could not be destroyed and recreated. Note: This function should not be used for container controls.

In the process of destroying and recreating the control, this function saves and restores both font information and standard properties stored only in the window and which would otherwise be erased when the window is destroyed (this includes the Enabled, TabIndex, TabStop, and Visible properties).

One use for this function is to set window style bits. Windows stores a number of style bits that specify the appearance and behavior of the window associated with each form and control. You should use the SetWindowWord() API function to change those style bits that cannot be modified through properties. However, there are several bits that are ignored if they are set after the window has been created. These bits must instead be specified when the window is created. Visual Basic handles creating all windows automatically and doesn't allow you to specify style bits used to create the window. The vbRecreateCtrl function allows you to change the style bits associated with a form or control and then destroy the window and recreate it.

See Also:	vbGetCtrlModel


vbSetData

Declaration:	Declare Sub vbSetData Lib "VBHELPER.DLL" (ByVal Pointer As Long, Variable As Any, ByVal nCount As Integer,)

Description:	Copies data from Variable to the memory location pointed to by Pointer. nCount specifies the number of bytes to be copied. This function is useful if you need to access data not within your program.

See Also:	vbGetData


vbVarPtr

Declaration:	Declare Function vbVarPtr Lib "VBHELPER.DLL" (Variable As Any) As Integer

Description:	Returns the offset portion of Variable's address.

Note that there are special considerations when obtaining the address of string variables.

ee Also:	vbVarSeg, vbGetLongPtr


vbVarSeg

Declaration:	Declare Function vbVarSeg Lib "VBHELPER.DLL" (Variable As Any) As Integer

Description:	Returns the segment portion of Variable's address.

Note that there are special considerations when obtaining the address of string variables.

See Also:	vbVarPtr, vbGetLongPtr


String Addresses

Visual Basic strings contain a special string header that contains the string length and other information. Windows, DOS and the ROM BIOS do not recognize this header. When you need to obtain the address of a string that will be used by Windows, DOS or the ROM BIOS, you must pass it using the ByVal clause. For example:

i% = vbVarPtr(ByVal myString$)

Even though ByVal normally means to send the value of a variable instead of the address, when applied to string variables it causes Visual Basic to pass the address of the actual string instead of the address of the string header.


Revision History
Revision History:

This section documents the changes and additions made to VB-Helper. Revisions are listed with the most recent version first.

Version:	Modification(s):

1.02	Fixed bug in the Snooper demo program that caused the Windows version to be incorrect when run on Windows for Workgroups.

1.01	Fixed bug that prevented vbPeek and vbPoke from working correctly.

Added vbPeekw, vbPokew, vbOutw and vbInpw routines to compliment their byte-oriented counterparts.

Added new vbGetFullPath routine. This routine performs the same functionality as vbFullPath but accepts and returns Visual Basic strings for convenience. vbFullPath is still included for compatibility.

Added new VB demo program, Snooper that shows how to detect various system information. Much of this information can be obtained without the use of VB-Helper so it also serves as a general-purpose VB demo program.

1.00.002	Added vbRecreateCtrl and vbGetCtrlModel subroutines. Changed the order of parameters for vbSetData and vbGetData, and also corrected an error in the declaration for these routines. Other minor adjustments.

1.00.001	Original version